package com.saibo.spider.commons;

import com.saibo.spider.utils.FileUtil;
import com.saibo.spider.utils.HttpRequestUtil;
import org.apache.http.client.methods.CloseableHttpResponse;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class RequestSogouVerifyCode {
	public static CloseableHttpResponse sendAntispider(String referer, Map<String, String> param) {
		String url = "http://weixin.sogou.com/antispider/thank.php";
		Map<String, String> mss = new HashMap<String, String>();
		mss.put("Accept", "application/json, text/javascript, */*; q=0.01");
		mss.put("Accept-Encoding", "gzip, deflate");
		mss.put("Accept-Language", "zh-CN,zh;q=0.8");
		mss.put("User-Agent",
				"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
		mss.put("X-Requested-With", "XMLHttpRequest");
		String cookie = FileUtil.txt2String(new File("D:/sogou.txt"));// 读取保存在本地的已经登陆的Cookie信息
		mss.put("Cookie", cookie);
		mss.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		mss.put("Referer", referer);
		mss.put("Origin", "http://weixin.sogou.com");
		mss.put("Connection", "keep-alive");
		mss.put("Host", "weixin.sogou.com");
		CloseableHttpResponse httpResponse = HttpRequestUtil.postRequestMethod(url, mss, param);
		return httpResponse;
	}
}
